<template>
  <div>
    <h1>这是 Home Page</h1>
    <input type="text" v-model="testVal" @keyup="setCount" />
  </div>
</template>

<script>
import { ref } from 'vue';
import { useStore } from "vuex";
import { 
  SET_TEST
} from '@/store/actionTypes';

export default {
  name: 'Home',
  setup(props, { emit }) {
    const store = useStore();
    const testVal = ref('');
    const setCount = (e) => {
      if (e.key == 'Enter' && testVal.value.trim().length) {
        store.dispatch(SET_TEST, testVal.value);

        testVal.value = '';
      }
    }

    return {
      testVal,
      setCount
    }
  }
}
</script>

<style>

</style>